package com.twu.biblioteca;

import java.io.*;
import java.util.ArrayList;
import java.util.logging.Logger;



public class MoviesLibraryController {

    private MoviesLibrary moviesLibrary;            // movie library object
    private String MOVIE_LIST_FILE="";
    Logger logger;

    MoviesLibraryController(String movieListFileName,Logger logger)
    {
        MOVIE_LIST_FILE=movieListFileName;
        this.logger=logger;

        moviesLibrary=new MoviesLibrary(MOVIE_LIST_FILE,logger);
    }

    void displayAllMoviesToConsole()
    {
        displayHeaderInformation();

        ArrayList<Movie> movies=moviesLibrary.getAllMovies();
        for(Movie movie:movies)
        {
            System.out.print(movie.getMovieName() + " | " + movie.getYearOfRelease() + " | " + movie.getDirector() + " | ");
            if(movie.getRating()==-1)
                System.out.println("N/A");
            else
                System.out.println(movie.getRating());

        }
        System.out.println();
    }

    private void displayHeaderInformation()
    {
        System.out.println("List of movies in the library:");
        System.out.println("-----------------------------------------------------------");
        System.out.println("Name       |  Year of Release  |    Director    |   Rating");
        System.out.println("-----------------------------------------------------------");
    }



}
